import '../index.dart';

enum LoadStatus {
  loadNot,
  loading,
  loadSuccess,
  loadFail,
}

class PageData<T> {
  static const int initCurrent = 1;
  static const int initSize = 20;

  //页面请求相关数据
  late int current = initCurrent;
  late LoadStatus loadStatus = LoadStatus.loadNot;
  late Map<String, dynamic> queryParameters;
  int? code = -1;
  DioErrorType? errorType;
  late String hint = "暂无数据";
  List<T> items = [];
  T? item;

  Map<String, dynamic> newQueryParameters(
      {int current = initCurrent, int size = initSize}) {
    queryParameters = {
      'current': current,
      'size': size,
    };
    return queryParameters;
  }

  Map<String, dynamic> moreQueryParameters() {
    Map<String, dynamic> moreQueryParameters = {};
    moreQueryParameters.addAll(queryParameters);
    moreQueryParameters['current'] = current + 1;
    return moreQueryParameters;
  }
}
